package com.triumphxx.testcase.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author:triumphxx
 * @Date: 2025/9/24
 * @Time: 11:30
 * @微信公众号：思考集结处
 * @网站：http://blog.triumphxx.com.cn
 * @GitHub https://github.com/triumphxx
 * @Desc: 工具函数
 **/

public class PubFun {
    /**
     * 得到当前系统日期 author: YT
     *
     * @return 当前日期的格式字符串, 日期格式为"yyyy-MM-dd"
     */
    public static String getCurrentDate() {
        //		String pattern = "yyyy-MM-dd";
//		SimpleDateFormat df = new SimpleDateFormat(pattern);
//		Date today = new Date();
//		String tString = df.format(today);
//		return tString;
        GregorianCalendar tGCalendar = new GregorianCalendar();
        StringBuffer tStringBuffer = new StringBuffer(10);
        int sYears = tGCalendar.get(Calendar.YEAR);
        tStringBuffer.append(sYears);
        tStringBuffer.append('-');
        int sMonths = tGCalendar.get(Calendar.MONTH) + 1;
        if (sMonths < 10) {
            tStringBuffer.append('0');
        }
        tStringBuffer.append(sMonths);
        tStringBuffer.append('-');
        int sDays = tGCalendar.get(Calendar.DAY_OF_MONTH);
        if (sDays < 10) {
            tStringBuffer.append('0');
        }
        tStringBuffer.append(sDays);
        return tStringBuffer.toString();
    }

    public static String getCurrentTime() {
        //		String pattern = "HH:mm:ss";
//		SimpleDateFormat df = new SimpleDateFormat(pattern);
//		Date today = new Date();
//		String tString = df.format(today);
//		return tString;
        GregorianCalendar tGCalendar = new GregorianCalendar();
        StringBuffer tStringBuffer = new StringBuffer(8);
        int sHOUR = tGCalendar.get(Calendar.HOUR_OF_DAY);
        if (sHOUR < 10) {
            tStringBuffer.append('0');
        }
        tStringBuffer.append(sHOUR);
        tStringBuffer.append(':');
        int sMINUTE = tGCalendar.get(Calendar.MINUTE);
        if (sMINUTE < 10) {
            tStringBuffer.append('0');
        }
        tStringBuffer.append(sMINUTE);
        tStringBuffer.append(':');
        int sSECOND = tGCalendar.get(Calendar.SECOND);
        if (sSECOND < 10) {
            tStringBuffer.append('0');
        }
        tStringBuffer.append(sSECOND);
        return tStringBuffer.toString();
    }
}
